package io.renren.modules.edu.controller;

import io.renren.common.utils.Result;
import io.renren.modules.edu.dto.TEduCourseDTO;
import io.renren.modules.edu.service.TEduCourseService;
import io.renren.modules.edu.vo.EduCourseTableVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

/**
 * 课程表
 *
 * @author zwp zwp
 * @since 1.0.0 2022-07-11
 */
@RestController
@RequestMapping("edu/course")
@Api(tags="课程表")
public class TEduCourseController {

    @Autowired
    private TEduCourseService tEduCourseService;

    /**
     * 用户课程表数据(数据权限过滤)
     */
    @GetMapping("/courseList")
    public Result<List<EduCourseTableVO>> courseList(@RequestParam Map<String, Object> params){
        List<EduCourseTableVO> eduCourseTableVOList = tEduCourseService.courseList(params);
        return new Result<List<EduCourseTableVO>>().ok(eduCourseTableVOList);
    }

    /**
     * 增加用户课程表数据
     * @param dto
     * @return
     */
    @PostMapping("/addCourse")
    public Result<Map<String, Object>> addCourse(@RequestBody TEduCourseDTO dto) {
        tEduCourseService.addCourse(dto);
        return new Result<Map<String, Object>>();
    }

    /**
     * 删除用户课程表数据
     * @param id
     * @return
     */
    @DeleteMapping("/deleteCourse/{id}")
    public Result<Map<String, Object>> deleteCourse(@PathVariable Long id) {
        tEduCourseService.deleteCourse(id);
        return new Result<Map<String, Object>>();
    }
}
